package com.ruoyi.recipe.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.recipe.domain.RecipeDish;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.recipe.mapper.RecipeDishItemMapper;
import com.ruoyi.recipe.domain.RecipeDishItem;
import com.ruoyi.recipe.service.IRecipeDishItemService;
import com.ruoyi.common.core.text.Convert;

/**
 * 材料Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-23
 */
@Service
public class RecipeDishItemServiceImpl implements IRecipeDishItemService 
{
    @Autowired
    private RecipeDishItemMapper recipeDishItemMapper;

    /**
     * 查询材料
     * 
     * @param itemId 材料主键
     * @return 材料
     */
    @Override
    public RecipeDishItem selectRecipeDishItemByItemId(Long itemId)
    {
        return recipeDishItemMapper.selectRecipeDishItemByItemId(itemId);
    }

    /**
     * 查询材料列表
     * 
     * @param recipeDishItem 材料
     * @return 材料
     */
    @Override
    public List<RecipeDishItem> selectRecipeDishItemList(RecipeDishItem recipeDishItem)
    {
        return recipeDishItemMapper.selectRecipeDishItemList(recipeDishItem);
    }

    @Override
    public int selectMaxItemSort(RecipeDishItem recipeDishItem) {
        return recipeDishItemMapper.selectMaxItemSort(recipeDishItem);
    }

    /**
     * 新增材料
     * 
     * @param recipeDishItem 材料
     * @return 结果
     */
    @Override
    public int insertRecipeDishItem(RecipeDishItem recipeDishItem)
    {
        recipeDishItem.setCreateTime(DateUtils.getNowDate());
        return recipeDishItemMapper.insertRecipeDishItem(recipeDishItem);
    }

    @Override
    public int batchInsertRecipeDishItem(List<RecipeDishItem> list) {
        return recipeDishItemMapper.batchInsertRecipeDishItem(list);
    }

    /**
     * 修改材料
     * 
     * @param recipeDishItem 材料
     * @return 结果
     */
    @Override
    public int updateRecipeDishItem(RecipeDishItem recipeDishItem)
    {
        recipeDishItem.setUpdateTime(DateUtils.getNowDate());
        return recipeDishItemMapper.updateRecipeDishItem(recipeDishItem);
    }

    /**
     * 批量删除材料
     * 
     * @param itemIds 需要删除的材料主键
     * @return 结果
     */
    @Override
    public int deleteRecipeDishItemByItemIds(String itemIds)
    {
        return recipeDishItemMapper.deleteRecipeDishItemByItemIds(Convert.toStrArray(itemIds));
    }

    /**
     * 删除材料信息
     * 
     * @param itemId 材料主键
     * @return 结果
     */
    @Override
    public int deleteRecipeDishItemByItemId(Long itemId)
    {
        return recipeDishItemMapper.deleteRecipeDishItemByItemId(itemId);
    }

    @Override
    public int deleteRecipeDishItemByDishId(Long dishId) {
        return recipeDishItemMapper.deleteRecipeDishItemByDishId(dishId);
    }

    @Override
    public int deleteRecipeDishItemByDishIds(String[] dishIds) {
        return recipeDishItemMapper.deleteRecipeDishItemByDishIds(dishIds);
    }
}
